import Layout from '@/views/layout/Layout';
import EmptyLayout from '@/views/layout/emptyLayout';

// 控制这系列页面的权限
const authData = {
  userAuthManage: ['auth:role:', 'auth:operator:'], // 权限设置
  user: ['crm:userList:'], // 用户设置
  ContractProcess: ['crm:legal:process'], // 流程设置
  systemSetting: ['auth:system:', 'system:ipSeries:read', 'system:cost:read'], // 通用设置
  userHandover: ['auth:handover:read'], // 交接管理
  operatorLogManage: ['auth:log:'], // 操作日志
  BPManage: ['crm:BPManage:read'] // BP管理
};
let pageAllAuth = [];
for (const key in authData) {
  pageAllAuth = pageAllAuth.concat(authData[key]);
}

// 设置
const settingRouter = [{
  path: '/system',
  component: Layout,
  redirect: '/system/role',
  name: 'systemPage',
  meta: { title: '设置', icon: 'sidebar-setting', authControl: pageAllAuth },
  children: [
    {
      path: 'role',
      name: 'userAuthManage',
      component: () => import('@/views/auth/role/index'),
      meta: { title: '权限设置', isSeal: false, keepAlive: true, isChange: true, headerBarShow: false, authControl: authData.userAuthManage }
    },
    {
      path: 'operator',
      name: 'operatorManage',
      component: () => import('@/views/auth/operator/index'),
      meta: { activeMenu: '/system/role', title: '操作员管理', keepAlive: true, isChange: true, headerBarShow: false }, // headerBarShow 为true显示头像
      hidden: true
    },
    {
      path: 'user',
      name: 'user',
      component: () => import('@/views/user/index'),
      meta: { title: '用户设置', keepAlive: true, isChange: true, headerBarShow: false, authControl: authData.user, mt: 2 } // headerBarShow 为true显示头像
    },
    {
      path: 'process',
      name: 'ContractProcess',
      component: () => import('@/views/legal/process/index'),
      meta: { title: '流程设置', keepAlive: true, isChange: true, headerBarShow: false, authControl: authData.ContractProcess } // authControl: ['crm:legal:process']
    },
    {
      path: 'setting',
      name: 'systemSetting',
      component: () => import('@/views/user/settingPage'),
      meta: { authControl: authData.systemSetting, title: '通用设置', keepAlive: false, isChange: true, headerBarShow: false }
    },
    {
      path: 'userHandover',
      component: () => import('@/views/user/userHandover/index'),
      name: 'userHandover',
      meta: { title: '交接管理', authControl: authData.userHandover, isSeal: false, keepAlive: true, headerBarShow: false, isChange: true }
    },
    {
      path: 'log',
      name: 'operatorLogManage',
      component: () => import('@/views/auth/log/index'),
      meta: { title: '操作日志', keepAlive: false, isChange: true, headerBarShow: false, authControl: authData.operatorLogManage }
    },
    {
      path: 'department',
      name: 'departmentManage',
      component: () => import('@/views/user/departmentManage/index'),
      meta: { title: '部门管理', keepAlive: false, isChange: true, headerBarShow: false }
    },
    {
      path: 'BP',
      name: 'BPManage',
      component: () => import('@/views/user/BPManage/index'),
      meta: { title: 'BP管理', keepAlive: false, isChange: false, headerBarShow: false, authControl: authData.BPManage }
    },
    {
      path: 'deletedDept',
      name: 'deletedDept',
      component: () => import('@/views/user/departmentManage/deletedDept'),
      meta: { activeMenu: '/system/department', title: '已删除', keepAlive: false, isChange: true, headerBarShow: false }, // headerBarShow 为true显示头像
      hidden: true
    },
    {
      path: 'loginPageConfig',
      name: 'loginPageConfig',
      component: () => import('@/views/system/loginPageConfig'),
      meta: { title: '登录页配置', keepAlive: false, isChange: true, headerBarShow: true },
      hidden: true
    },
    /**
     * 内页
     */
    /** 权限设置 */
    {
      path: 'rolecreate',
      name: 'createRole',
      component: () => import('@/views/auth/role/create'),
      meta: { title: '新增角色', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/system/role' }, // headerBarShow 为true显示头像
      hidden: true
    },
    {
      path: 'roleedit/:roleId',
      name: 'authEditRole',
      component: () => import('@/views/auth/role/create'),
      meta: { title: '编辑角色', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/system/role' }, // headerBarShow 为true显示头像
      hidden: true
    },
    {
      path: 'operatorcreate',
      name: 'createOperator',
      component: () => import('@/views/auth/operator/create'),
      meta: { title: '新增操作员', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/system/role' }, // headerBarShow 为true显示头像
      hidden: true
    },
    {
      path: 'operatoredit/:operatorId',
      name: 'editOperator',
      component: () => import('@/views/auth/operator/create'),
      meta: { title: '编辑操作员', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/system/role' }, // headerBarShow 为true显示头像
      hidden: true
    },
    // 用户设置内页
    {
      path: 'create',
      component: () => import('@/views/user/create/index'),
      name: 'createUser',
      meta: { title: '新增用户', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/system/user' },
      hidden: true
    },
    {
      path: 'fileupload',
      component: () => import('@/views/order/upload/index'),
      name: 'fileupload',
      meta: { title: '文件上传', isSeal: false, keepAlive: false, headerBarShow: true, type: '0' },
      hidden: true
    },
    // 流程设置内页
    {
      path: 'processEdit/:id',
      name: 'ContractProcessEdit',
      hidden: true,
      component: () => import('@/views/legal/process/create'),
      meta: { paddingLeft: '42px', title: '审批流程', headerBarShow: false, activeMenu: '/system/process' }
    },
    {
      path: 'processCreate',
      name: 'ContractProcessCreate',
      hidden: true,
      component: () => import('@/views/legal/process/create'),
      meta: { paddingLeft: '42px', title: '审批流程', headerBarShow: true, activeMenu: '/system/process' }
    },
    // 新建交接
    {
      path: 'addHandover',
      component: () => import('@/views/user/userHandover/create/index'),
      name: 'addHandover',
      meta: { title: '新建交接', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/system/userHandover' },
      hidden: true
    },
    {
      path: 'handoverDetail/:id',
      component: () => import('@/views/user/userHandover/detail/index'),
      name: 'handoverDetail',
      meta: { title: '交接详情', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/system/userHandover' },
      hidden: true
    }
  ]
}, {
  path: '/process',
  component: EmptyLayout,
  name: 'processFormMake',
  hidden: true,
  meta: { title: '设置' },
  children: [
    {
      path: 'processCreateCustom',
      name: 'ContractProcessCreateCustom',
      component: () => import('@/views/legal/process/createCustomProcess'),
      meta: { title: '审批流程', headerBarShow: false, activeMenu: '/system/process' }
    },
    {
      path: 'processEditCustom/:id',
      name: 'ContractProcessEditCustom',
      component: () => import('@/views/legal/process/createCustomProcess'),
      meta: { title: '审批流程', headerBarShow: false, activeMenu: '/system/process' }
    }
  ]
}];

export default settingRouter;
